home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
451-475
/
disk_458
/
texify
/
texify.ced
< prev
next >
Wrap
Text File
|
1992-05-06
|
16KB
|
584 lines
/********************************************************************************/
/* ARexx program TeXify V 1.10 (Sep 90) */
/* */
/* Just put this ARexx program on a CygnusEd Fkey */
/* and edit your TeX source. When finish with editing, */
/* press the function key and you get your source */
/* Copyright 1990 showing up in TeXs preview. If not, you get your */
/* by Wolf-Juergen Faust cursor positioned at the error position with an */
/* Am Dorfgarten 10 error message. For a new TeXify version call FIDO */
/* W-6000 Frankfurt 50 +(49) 6173 2544 (HST DS) or contact me... */
/* Germany */
/* FIDO: 2:243/43.5 (Wolf Faust) */
/* UUCP: cbmvax.commodore.com!cbmehq!cbmger!venus!wfaust */
/* Tel: +(49) 69 5486556 */
/* */
/* YOU MUST ADOPT THE FIRST COMMANDS TO YOUR ENVIRONMENT !!!!!!!!!!!! */
/* ================================================================== */
/* (See the readme and ARexx files you MUST get with this file!) */
/* Versions needed: */
/* ARexx >= V 1.10 (tested: 1.10, 1.12, 1.14) */
/* CEDPro>= V 2.00 (tested: 2.10, 2.11, 2.12) */
/* TeX >= V 2.09o (tested: 2.09o, 2.09p) */
/* After adopting the first two commands: KS 1.2, 1.3, 2.0 (all versions tested)*/
/********************************************************************************/
/* Now, here's the command for starting TeX in backround. I offer you */
/* two examples. One for WShell and one for the normal Commodore shell. */
/* Shutting down TeX is simple in WShell/Conman: klick on the closegadget. */
/* For the normal TeX shell you have to type the usual CTRL-F. */
/* Commodore Shell version: (change all paths according to your system !) */
/* For Kickstart 2.0 users: delete all paths before resident shell commands!!! */
cmd1 = 'echo >t:tex1 "stack 10000"'
cmd2 = 'echo >t:tex2 "tex:c/tex -R"'
cmd3 = 'echo >t:tex3 "endcli"'
cmd4 = 'join t:tex1 t:tex2 t:tex3 to t:tex'
cmd5 = 'NewShell CON:0/11/640/180/Press_CTRL-F_to_close FROM t:tex'
/*** OR ***/
/* WShell version: (change only cmd5 ! cmd1-4 as above !) */
/* cmd5 = 'NewWsh FROM t:tex' */
/* Preview startup command: (change path according to your system !) */
preview = "run >nil: <nil: tex:c/preview"
/* Path for Manx's(!) Set command: (KS2.0: add path for Manxs SET!!!!!! */
setpath = "tex:c/Set"
/* CEDPro startup command: (change path according to your system !) */
ced = "dh0:c/ced"
/* Max. errors before TeXify stops TeX (default should be arround 3) */
errorcount = 3
/* Keyword for the TeX macropackage given in the first line (default: "macropackage") */
package = "macropackage"
/* Max. time needed between loading TeX, Preview... and showing up their Ports(default: 10) */
timeout = 10
/*** START (don't change anything after this...) ***/
/*** Return ***/
cr = '0A'X
/*** program receives answers ***/
options results
/*** now lets get to business with CygnusEd ***/
address 'rexx_ced'
/*** ask for the file name, sans directory of the current file ***/
status 21
srcfile = result
/*** What about the name ??! Valid ??***/
last = lastpos('.',srcfile)
do while ((srcfile = "") | (last=0))
if srcfile = "" then srcfile = "untitled.tex"
okay2 "ERROR ! TeXfile needs a name with suffix !"||cr||"Continue ?"
if result = 0 then exit 5
getfilename srcfile 'Give name for new TeX sourcefile...'
if result ~= "RESULT" then do
last = lastpos('.',result)
fullsrc = result
if last ~= 0 then do
save as result
status 21
srcfile = result
last = lastpos('.',srcfile)
end
else
srcfile = fullsrc
end
else
last = 0
end
/*** path+filename: maybe part of path is missing ! special code needed ***/
status 19
fullsrc = result
last = lastpos(':',fullsrc)
/*** current dir maybe needed for joining with incomplete path ***/
status 75
if last = 0 then fullsrc = result||fullsrc
last = lastpos('/',fullsrc)
if last~=0 then do
path = left(fullsrc,last)
texpath = left(fullsrc,last-1)
end
else do
last = lastpos(':',fullsrc)
path = left(fullsrc,last)
texpath = path
end
/*** change suffix of source to .log later...***/
srcnam = left(fullsrc,lastpos('.',fullsrc)-1)
/*** get suffix of current textfile ***/
sfx = right(srcfile,length(srcfile)-lastpos('.',srcfile))
/*** is suffix .tex ?? maybe just a wrong key ?? ***/
if upper(sfx) ~= 'TEX' then do
okay2 'Suffix ' sfx ' is not a TeX file !' cr||'Start TeX anyway ?'
if result = 0 then exit 5
end
/*** are there any changes ? do I have to save the text first ?? ***/
status 18
if result ~= 0 then do
save
end
/*** look out for macropackage in textfile ***/
status 46
y = result
status 47
x = result
'Beg of file'
status 55
macro = left(upper(result),length(result)-1)
'Jumpto' x+1 y+1
if left(macro,1) = "%" then do
macro = strip(strip(macro,'L','%'),'L')
if (pos(upper(package),macro) = 1) then do
macro = subword(strip(strip(substr(macro,length(package)+1),'L'),'L','='),1)
if pos('%',macro)>0 then do
macro = left(macro,pos('%',macro)-1)
end
macro = strip(macro,'T')
end
else macro = ""
end
else macro = ""
if macro ~= "" then do
/*** get contents of manx texformat environment ***/
address command setpath||" >t:tex1"
ti = time('S') + 5;
rc = 0
do while ((rc=0) & (time('S') < ti))
rc = open('log','t:tex1')
if rc = 0 then call delay(50)
end
if rc = 0 then do
okay1 "INTERNAL ERROR ! Can't read temporary file t:tex !"
exit 5
end
oldmacro = "PLAIN" /* default setting */
do until eof('log')
logline = upper(readln('log'))
if left(logline,10) = "TEXFORMAT=" then do
oldmacro = strip(strip(substr(logline,length("TEXFORMAT=")+1),'L'),'T')
end
end
call close 'log'
/*** set up new macropackage ***/
if oldmacro ~= macro then do
address command setpath||' texformat='||macro
if (show('P','AmigaTeX')) then do
address 'AmigaTeX' 'Exit'
delay(20)
end
end
end
/*** It's time for support ! **/
if ~show('l','rexxsupport.library') then
if ~addlib('rexxsupport.library',0,-30) then
do
Okay1 'Error ! No rexxsupport.library !'
exit 5
end
/*** Hey TeX ! Wakeup ! ***/
/*** If TeX is not running in backround, get it started ! ***/
if ~show('P','AmigaTeX') then do
address command cmd1
if RC > 9 then okay1 'Error ! Check TeXify configuration for starting TeX!'
address command cmd2
if RC > 9 then okay1 'Error ! Check TeXify configuration for starting TeX!'
address command cmd3
if RC > 9 then okay1 'Error ! Check TeXify configuration for starting TeX!'
address command cmd4
if RC > 9 then okay1 'Error ! Check TeXify configuration for starting TeX!'
address command cmd5
if RC > 9 then okay1 'Error ! Check TeXify configuration for starting TeX!'
/*** now give TeX time to showup ***/
ti = time('S') + timeout;
do while ((~show('P','AmigaTeX')) & (time('S') < ti))
call delay (50)
end
if ~show('P','AmigaTeX') then do
okay2 'Error ! TeX did not get started after 'timeout' seconds !' cr||'You may start TeX now by CLI and continue !'
if result = 0 then exit 5
end
end
/*** make path of activ file current path, so TeX can find .aux ... ***/
address 'AmigaTeX' 'CD' texpath
/*** check if path command is executed succesfully ***/
/*** if rc = 1 then TeX is busy ***/
if RC = 1 then do
okay1 'Ooops ! TeX is busy ! Try TeX in ** status !?'
exit 5
end
/*** if rc = 10 then path could not been found ***/
if RC = 10 then do
okay2 'ERROR ! Path ' texpath ' not accessable !' cr|| 'Shall I try it anyway ??'
if result = 0 then exit 5
end
/**** Reset counter for TeXifyLookNext.ced ***/
setclip('texlog',"0")
/*** just get shure there's no old misinterpreted .log .dvi file ***/
if exists(srcnam||'.log') then call delete(srcnam||'.log')
if exists(srcnam||'.dvi') then call delete(srcnam||'.dvi')
/*** now texify the textfile while showing TeXs prompting ***/
address 'AmigaTeX'
'ToFront'
/*** give TeX something to do... ***/
'TeXify' srcfile
/*** is TeX in input status ** ? ***/
if RC = 1 then do
Okay1 'Error ! Can not TeXify your file !' cr||'TeX is not in ** status !'
exit 5
end
/*** wait until TeX gets finished ***/
'NextPrompt'
'NextPrompt'
/*** get status of TeX for analysing ***/
'Prompt'
prompt = getclip('AmigaTeX.Prompt')
/*** if RC = 1 then TeX was not waiting for incoming Data... ** ***/
if RC = 1 then do
/*** Activate CEDPro ***/
if ~show('P','rexx_ced') then do
address command ced||" "||fullsrc
Delay(30)
end
address 'rexx_ced'
'jump to file' fullsrc
if result = 0 then do
'Open new'
'Open' fullsrc
end
'CedToFront'
Okay1 'Error ! TeX does not behave right !'
exit 5
end
/*** Ooops ! if this happens, there is something wrong in your source ! ***/
if prompt = "?" then do
n = 1;
do while (prompt = "?" & n<=errorcount)
/*** get position of error from TeX ***/
'ErrorLoc'
error = getclip('AmigaTeX.ErrorLoc')
parse var error filename.n line.n pos.n
if n<errorcount then do
'TeXify '||cr
'NextPrompt'
'NextPrompt'
end
n = n+1
/*** get status of TeX for analysing ***/
'Prompt'
prompt = getclip('AmigaTeX.Prompt')
if RC = 1 then do
/*** Activate CEDPro ***/
if ~show('P','rexx_ced') then do
address command ced||" "||fullsrc
Delay(30)
end
address 'rexx_ced'
'jump to file' fullsrc
if result = 0 then do
'Open new'
'Open' fullsrc
end
'CedToFront'
okay1 'Error ! TeX does not behave right !'
/*** now TeX window can disappear ***/
address 'AmigaTeX' 'ToBack'
exit 5
end
end
n = n-1
/*** now TeX can disappear ***/
'ToBack'
'Abort'
/*** Do I have to start CEDPro? Activate CEDPro ! ***/
if ~show('P','rexx_ced') then do
address command ced||" "||fullsrc
Delay(30)
end
address 'rexx_ced'
'jump to file' fullsrc
if result = 0 then do
'Open new'
'Open' fullsrc
end
'CedToFront'
/*** wait a bit for TeX to finish .log file ***/
address 'AmigaTeX' 'NextPrompt' /* TeX may need it twice... doesn't matter anyway */
address 'AmigaTeX' 'NextPrompt'
/*** if there's no .log file, there's no explaining for your mistake ! ***/
if ~exists(srcnam|| '.log') then do
okay1 'Ooops ! Error in this line ! No .log file !'
exit 5
end
/*** TeX may be finish with .log, but AmigaDos may need time! ***/
/*** Specially 68020/30 needs checking ! ***/
ti = time('S') + 3;
rc = 0
do while ((rc=0) & (time('S') < ti))
rc = open('log',srcnam||'.log')
if rc = 0 then call delay(50)
end
if rc = 0 then do
okay1 "ERROR ! Error in this line !" cr|| "Can't open the existing .log file !"
exit 5
end
cause = 1
lin = 1
do until eof('log')
logline = readln('log')
if left(logline,2) = "! " then do
error.cause = right(logline,length(logline)-2)
cause = cause + 1
end
else if left(logline,2) = "l." then do
logline = subword(logline,1,1)
logline = delstr(logline,1,2)
if logline ~= line.lin then do
pos.lin = 0
filename.lin = "!"
line.lin=logline
end
lin = lin + 1
end
end
call close 'log'
lin = lin-1
if (lin > n) & (lin < errorcount) then n = lin
rc = open('log','t:tex.log',write)
if rc = 0 then do
okay1 "ERROR ! Can't write errorfile in t: !"
exit 5
end
lin = 1
do lin = 1 for n
call writeln 'log',line.lin ||" "|| pos.lin ||" "|| filename.lin ||" "|| error.lin
end lin
call close out
setclip('texlog',"1")
setclip('texpath',path)
sfx= "."||sfx
setclip('texsfx',sfx)
'jump to file' filename.1
if result = 0 then do
if exists(path||filename.1) then do
'open new'
'open' path||filename.1
'jumpto' line.1 pos.1
okay1 error.1
exit 5
end
if exists(filename.1) then do
'open new'
'open' path||filename.1
'jumpto' line.1 pos.1
okay1 error.1
exit 5
end
'jump to file' filename.1||sfx
if result = 0 then do
if exists(path||filename.1||sfx) then do
'open new'
'open' path||filename.1||sfx
'jumpto' line.1 pos.1
okay1 error.1
exit 5
end
if exists(filename.1||sfx) then do
'open new'
'open' path||filename.1||sfx
'jumpto' line.1 pos.1
okay1 error.1
exit 5
end
'jumpto' line.1 pos.1
okay1 "Ooops ! Error in "||filename.1||" TeX file !"||cr||error.1||cr||"Error in line:"||line.1||" pos:" pos.1
exit 5
end
end
'jumpto' line.1 pos.1
okay1 error.1
exit 5
end
/*** now TeX window can disappear ***/
'ToBack'
/*** if prompt = * then TeX aborted ... should be a missing \end ***/
if prompt = "*" then do
'Abort'
/*** Activate CEDPro ***/
if ~show('P','rexx_ced') then do
address command ced||" "||fullsrc
Delay(30)
end
address 'rexx_ced'
'jump to file' fullsrc
if result = 0 then do
'Open new'
'Open' fullsrc
end
'CedToFront'
okay1 'Ooops ! TeX ended in * status !' cr|| 'Maybe a forgotten \end ??'
exit 5
end
/*** seems that everything worked fine with tex ***/
if prompt = '**' then do
/*** pop up CygnusEd screen, so you get there when quiting preview ***/
if show('P','rexx_ced') then do
address 'rexx_ced'
'CEDTOFRONT'
end
/*** cut suffix from sourcefiles name; preview don't like suffix ***/
fullsrc = left(fullsrc,lastpos('.',fullsrc)-1)
/*** do I have to start preview first ? ***/
if ~show('P','TeXpreview') then address command preview||" "||fullsrc
else do
address 'TeXpreview'
'ToFront'
'activate'
end
/*** now give preview time to showup ***/
ti = time('S') + timeout;
do while ((~show('P','TeXpreview')) & (time('S') < ti))
call delay(50)
end
if ~show('P','TeXpreview') then do
/*** Activate CEDPro ***/
if ~show('P','rexx_ced') then do
address command ced||" "||fullsrc
Delay(30)
end
address 'rexx_ced'
'jump to file' fullsrc
if result = 0 then do
'Open new'
'Open' fullsrc
end
'CedToFront'
okay1 "ERROR ! Couldn't start Preview after "timeout" secs !" cr||" You may start Preview now by CLI !" cr||" Your .dvi file seems to be fine !"
exit 5
end
exit
end
/*** unknown prompt from TeX !!!!!! ***/
/*** now TeX can disappear ***/
'ToBack'
'Abort'
/*** Activate CEDPro ***/
if ~show('P','rexx_ced') then do
address command ced||" "||fullsrc
Delay(30)
end
address 'rexx_ced'
'jump to file' fullsrc
if result = 0 then do
'Open new'
'Open' fullsrc
end
'CedToFront'
/*** wait a bit for TeX to finish .log file ***/
'NextPrompt' /* TeX may need it twice... doesn't matter anyway */
'NextPrompt'
/*** if there's no .log file, there's no explaining for your mistake ! ***/
if ~exists(srcnam|| '.log') then do
okay1 'Ooops ! TeX aborted in unknown status !'|| cr || "Can't open any .log file !"
exit 5
end
/*** TeX may be finish with .log, but AmigaDos may need time! ***/
/*** Specially 68020/30 needs checking ! ***/
ti = time('S') + 3;
rc = 0
do while ((rc=0) & (time('S') < ti))
rc = open('log',srcnam||'.log')
if rc = 0 then call delay(50)
end
if rc = 0 then do
okay1 "ERROR ! TeX aborted in unknown status !"||cr||"Can't open the existing .log file !"
exit 5
end
logline = ""
do until (left(logline,2) = "! " )
logline = readln('log')
if eof('log') then do
/*** no '! ' found in file ***/
call close 'log'
okay1 "Ooops ! TeX aborted in unknown status !"||cr||"No error in .log file ! Try it by hand !"
exit 5
end
end
errline = ""
do until (left(errline,2) = "l.")
errline = readln('log')
if eof('log') then do
/*** no '! ' found in file ***/
call close 'log'
okay1 "Ooops ! TeX aborted in unknown status !"||cr||"There is an unknown error in TeX file !!!"
exit 5
end
end
call close 'log'
errline = subword(errline,1,1)
errline = delstr(errline,1,2)
/*** '! ' found in .log file; show error explanation ***/
logline = right(logline,length(logline)-2)
strip(logline,'B')
'jumpto' errline 1
okay1 "Ooops ! TeX aborted in unknown status !"||cr||"Error in unknown TeX source ! Line: "||errline||cr||logline
exit 5
end